#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,M=1e6+10;
int T,n,m,L,V,d[M],v[M],a[M],t[M],p[M],s[M],tot,lm,ans;
struct Dd{
    int ll,rr;
}c[N];
int askl(int x){
    int l=1,r=m,mid;
    while(l<r){
        mid=(l+r)/2;
        if(t[mid]<x){
            l=mid+1;
        }
        else{
            r=mid;
        }
    }
    return l;
}
int askr(int x){
    int l=1,r=m,mid;
    while(l<r){
        mid=(l+r+1)/2;
        if(t[mid]>x){
            r=mid-1;
        }
        else{
            l=mid;
        }
    }
    return l;
}
bool cmp(Dd x,Dd y){
    if(x.rr==y.rr)
        return x.ll<y.ll;
    return x.rr<y.rr;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int i,j,l,r;
    scanf("%d",&T);
    while(T--){
        memset(p,0,sizeof(p));
        memset(s,0,sizeof(s));
        tot=0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(i=1;i<=n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        }
        for(i=1;i<=m;i++){
            scanf("%d",&t[i]);
            p[t[i]]++;
        }
        sort(t+1,t+m+1);
        s[0]=p[0];
        for(i=1;i<=L;i++){
            s[i]=s[i-1]+p[i];
        }
        tot=0;
        for(i=1;i<=n;i++){
            bool f=0;
            if(a[i]>0&&v[i]*v[i]+2*a[i]*(L-d[i])>V*V){
                f=1;
                if(v[i]>V){
                    l=d[i];
                }
                else{
                    l=(V*V-v[i]*v[i])/(2*a[i])+1;
                    l+=d[i];
                }
                r=L;
            }
            if(a[i]==0&&v[i]>V){
                f=1;
                l=d[i];
                r=L;
            }
            if(a[i]<0&&v[i]>V){
                a[i]=-a[i];
                f=1;
                l=d[i];
                if(v[i]*v[i]-2*a[i]*(L-d[i])>V*V){
                    r=L;
                }
                else{
                    r=(v[i]*v[i]-V*V)/(2*a[i]);
                    if(2*a[i]*r==v[i]*v[i]-V*V)
                        r--;
                    r+=d[i];
                }
            }
            //cout<<f<<'*'<<l<<' '<<r<<endl;
            if(f&&(p[l]||(s[r]-s[l]>0))){
                //cout<<i<<'*'<<tot<<endl;
                tot++;
                c[tot].ll=askl(l);
                c[tot].rr=askr(r);
                //cout<<cnt<<' '<<c[cnt].ll<<'*'<<c[cnt].rr<<endl;
            }
        }
        cout<<tot<<' ';
        sort(c+1,c+tot+1,cmp);
        lm=-1;
        ans=0;
        for(i=1;i<=tot;i++){
            if(c[i].ll>lm){
                lm=c[i].rr;
                ans++;
            }
        }
        ans=m-ans;
        cout<<ans<<endl;
    }
    return 0;
}
